package vip.websky.project.module.dto;

import lombok.Data;
import vip.websky.project.module.dto.response.common.PageResponseDTO;

import java.io.Serializable;

/**
 * 返回参数
 *
 * @author: yong.Yang
 * @createAt: 2017/8/1-21:49
 */
@Data
public class ResponseDTO<T> extends PageResponseDTO implements Serializable {
    private boolean success;
    private String statusCode;
    private String statusMessage;
    private T result;

    public void setResult( T result ) {
        this.success = true;
        this.statusCode = "200";
        this.statusMessage = "success!";
        this.result = result;
    }

    public ResponseDTO() {
    }

    public ResponseDTO( boolean success, String statusCode, String statusMessage, T result ) {
        this.success = success;
        this.statusCode = statusCode;
        this.statusMessage = statusMessage;
        this.result = result;
    }

    public ResponseDTO( T result ) {
        this(true,"200","success!",result);
    }

    public ResponseDTO( String statusCode, String statusMessage, T result ) {
        this.success = true;
        this.statusCode = statusCode;
        this.statusMessage = statusMessage;
        this.result = result;
    }

    public ResponseDTO( String statusCode, String statusMessage ) {
        this(false,statusCode,statusMessage,null);
    }
}
